home *** CD-ROM | disk | FTP | other *** search
- Path: hops.cs.jhu.edu!lasher
- From: lasher@hops.cs.jhu.edu (John E. Davis)
- Newsgroups: comp.lang.c
- Subject: Do you see what is wrong?
- Date: 13 Mar 1996 18:01:10 GMT
- Organization: JHU computer science
- Message-ID: <4i72h6$2d4@blaze.cs.jhu.edu>
- NNTP-Posting-Host: hops.cs.jhu.edu
- X-Newsreader: TIN [version 1.2 PL2]
-
- Can someone point out what is wrong with this snippet of code?
- The problem is that I get a segmentation fault(core dumped) error when I
- hit ^d to send end of file. the error occurs at the place specified in
- the code. I would appreciate any/all ideas and any fixes that you might
- suggest. This was compiled on a system running some flavor of UNIX (not
- sure which)
-
-
- #include <stdio.h>
- #include <stdlib.h>
- #include <math.h>
-
- #define SIZE 200
-
- int closest(float [], float [], int [], float [], int);
- float distance(float, float, float, float);
-
- void main()
- {
- float xtemp, ytemp, Xposition[SIZE], Yposition[SIZE], totalLength[1];
- int j = -1, n, i, distance, nextCoord, current = 0, status[SIZE];
-
- totalLength[1] = 0;
-
- /* variables not used in this section are used in other non-relevant
- parts of the code */
-
- printf("Enter coordinates in the form: x y\n ");
-
- for( n = 0; n < SIZE; n++, j++ ) {
- if( scanf("%f%f", &xtemp, &ytemp) != EOF)
- {
- Xposition[n] = xtemp;
- Yposition[n] = ytemp;
- }
- else {
- printf("Done entering Numbers");
- n = SIZE;
- printf("\n%f %f", Xposition[j], Yposition[j]);
- } /* <== I get a core dump right here. _after_ executing the
- stuff in the else statemnet */
- }
- }
-
-
-
-
-
-
- --
- _____..---======+*+=======---.._____
- __ ________________ __,-='=====____ ============== _____=====`=
- (._I________________I__) - _-=_/ `------=+=-------'
- / /__...---==='---+---_' jdavis@jhu.edu
- '----'---.___ - _ = _.-' lasher@hops.cs.jhu.edu
- `-------' gargamel@jhunix.hcf.jhu.edu
- an461864@anon.penet.fi gargamel@jhuvms.hcf.jhu.edu
- (anonymous)
-
- "To boldly go where no man has gone before... MY HOMEPAGE!! please visit..."
- http://hops.cs.jhu.edu/~lasher/
-
- UNIX is a very user-friendly operating system ...
- ... it's just picky about who it's friends with
-